import { getConfig } from '@/api/admin/sys-public-param'
import { patch } from '@/store/module'

export default {
  namespaced: true,
  state: {
    formButtonPosition: null,
    ureportPrintIpAddr: null,
    userPasswordStrength: null,
    kkFileViewAddr: null
  },
  actions: {
    async init({ commit }) {
      const res = await getConfig(['FORM_BUTTON_POSITION', 'UREPORT_PRINT_IP_ADDR', 'KK_FILE_VIEW_ADDR', 'USER_PASSWORD_STRENGTH'])
      const config = {}
      res.data.data.forEach(value => {
        config[value.key] = value.value
      })
      commit('patch', config)
    }
  },
  mutations: {
    patch(state, config) {
      patch(state, config)
    }
  }
}
